home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F33680_within.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-20  |  1.7 KB  |  46 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  3. xmlns:MyWithinEpsController="MyWithinEpsController"
  4. exclude-result-prefixes="xsl msxsl MyWithinEpsController" 
  5. >
  6.  
  7.   <xsl:import href="buildListWhile.xsl"/>
  8.  
  9.   <MyWithinEpsController:MyWithinEpsController/>
  10.   
  11.    <xsl:variable name="vMyWithinEpsController" select="document('')/*/MyWithinEpsController:*[1]"/>
  12.   
  13.   <xsl:template name="within">
  14.      <xsl:param name="pGenerator" select="/.."/>
  15.      <xsl:param name="pParam0" select="/.."/>
  16.      <xsl:param name="Eps" select="0.1"/>
  17.   
  18.       <xsl:variable name="vResultList">
  19.           <xsl:call-template name="buildListWhile">
  20.             <xsl:with-param name="pGenerator" select="$pGenerator"/>
  21.             <xsl:with-param name="pParam0" select="$pParam0"/>
  22.             <xsl:with-param name="pController" select="$vMyWithinEpsController"/>
  23.             <xsl:with-param name="pContollerParam" select="$Eps"/>
  24.           </xsl:call-template>
  25.       </xsl:variable>
  26.       
  27.       <xsl:value-of select="msxsl:node-set($vResultList)/*[last()]"/>
  28.   </xsl:template>
  29.  
  30.   <xsl:template name="MyWithinEpsController" match="*[namespace-uri()='MyWithinEpsController']">
  31.      <xsl:param name="pList" select="/.."/>
  32.      <xsl:param name="pParams"/>
  33.      
  34.      <xsl:choose>
  35.          <xsl:when test="count($pList) < 2">1</xsl:when>
  36.          <xsl:when test="count($pList) >= 2">
  37.            <xsl:variable name="lastDiff" select="$pList[last()] - $pList[last() - 1]"/>
  38.            
  39.            <xsl:if test="not($lastDiff <= $pParams 
  40.                        and $lastDiff >= (0 - $pParams))">1</xsl:if>
  41.          </xsl:when>
  42.          <xsl:otherwise>1</xsl:otherwise>
  43.      </xsl:choose>
  44.   </xsl:template>
  45.  
  46. </xsl:stylesheet>